package com.clusterswisdom.horn.api.tmall.action.alipay;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.TmallInstance;
import com.clusterswisdom.horn.api.tmall.action.AbstractTmallAction;
import com.taobao.api.response.AlipayUserTradeSearchResponse;

public class UserTradeSearchAction extends AbstractTmallAction implements
		HornAction {

	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		AlipayUserTradeSearchResponse response = (AlipayUserTradeSearchResponse)TmallInstance.getInstance().executeRequest(param, "alipay", "searchUserTrade");
		if(response.isSuccess()) {
			return new HornResponse(true, response.getTradeRecords());
			
		} else {
			return super.getUnsuccessResponse(response);
			
		}
	}
}
